package recruit_handler

import (
	"peilian-api/app/global/bind"
	"peilian-api/app/global/errors"
	"peilian-api/app/model"
	"peilian-api/app/services/recruit_service"
	"peilian-api/utils/format"

	"github.com/gin-gonic/gin"
)

// 获取行业列表
func GetIndustry(ctx *gin.Context) {
	out := new(recruit_service.RecruitService).GetIndustry(ctx)
	format.NewResponseJson(ctx).SuccessObj(out)
}

// 获取地区列表
func GetAddress(ctx *gin.Context) {
	out := new(recruit_service.RecruitService).GetAddress(ctx)
	format.NewResponseJson(ctx).SuccessObj(out)
}

// 获取招聘列表
func GetRecruit(ctx *gin.Context) {
	var recruit model.RecruitReq
	if err := bind.ShouldBinding(ctx, &recruit); err != nil {
		format.NewResponseJson(ctx).Err(errors.PublicErrorCode, errors.ParamBindError)
		return
	}

	out, count, err := new(recruit_service.RecruitService).GetRecruit(ctx, recruit)
	if err != nil {
		format.NewResponseJson(ctx).Err(30002, err.Error())
		return
	}

	format.NewResponseJson(ctx).SuccessDataList(int(count), out)
}
